package org.example.day;

import java.util.Arrays;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/05/18 21:19
 */
public class Solution2644 {
    public static void main(String[] args) {

        Solution2644 solution2644 = new Solution2644();
        int[] nums = new int[]{4,7,9,3,9};
        int[] divisors = new int[]{5,2,3};
        System.out.println(solution2644.maxDivScore(nums, divisors));
    }

    public int maxDivScore(int[] nums, int[] divisors) {
        int max = 0;
        int index = 0;
        Arrays.sort(divisors);
        for(int i=0;i<divisors.length;i++){
            int count = 0;
            for(int j=0;j<nums.length;j++){
                if(nums[j] % divisors[i] == 0){
                    count++;
                    if( count > max){
                        max = count;
                        index = i;
                        
                    }
                }
            }
        }
        return divisors[index];
    }
}
